<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		<!-- View 视图 -->
		<div id="app">
			{{msg}}<br />
			<button @click="add">按了{{count}}</button>
			<div>{{count}}</div><br />

			<input type="text" v-model="num1" />
			<select v-model="op">
				<option>+</option>
				<option>-</option>
				<option>*</option>
				<option>/</option>
			</select>
			<input type="text" v-model="num2" />
			<input type="button" value="=" @click="calc" />
			<input type="text" v-model="result" />
		</div>

		<script type="text/javascript">
			// 创建 View-Model
			const vm = Vue.createApp({
				data() {
					// 返回一个模型Model
					return {
						msg: "Hello world,Vue!",
						count: 0,
						num1: "",
						num2: "",
						op: "+",
						result: ""
					}
				},
				methods: {
					add() {
						this.count++;
					},
					calc() {
						switch (this.op) {
							case "+":
								this.result = parseInt(this.num1) + parseInt(this.num2);
								break;
							case "-":
								this.result = parseInt(this.num1) - parseInt(this.num2);
								break;
							case "*":
								this.result = parseInt(this.num1) * parseInt(this.num2);
								break;
							case "/":
								this.result = parseInt(this.num1) / parseInt(this.num2);
								break;
						}
					}

				}
			});
			// 挂载到视图上 （即告诉vue去控制哪个视图元素)
			vm.mount("#app");
		</script>


	</body>
</html>
